<template>
  <!--  template中书写组建的结构-->
  <el-form ref="form" label-width="auto" :model="form" :inline="inline">
    <el-form-item v-for="item in formLabel" :key="item.label" :label="item.label">
      <el-input
          v-if="item.type==='input'"
          :placeholder="`请输入` + item.label"
          v-model="form[item.model]"
      ></el-input>
      <el-switch
          v-if="item.type === 'switch'"
          v-model="form[item.model]"
      ></el-switch>
      <!--      value-format="yyyy-MM-dd"      定义日期显示格式-->
      <el-date-picker
          v-if="item.type==='date'"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择日期"
          v-model="form[item.model]"
      ></el-date-picker>
      <el-select
          v-if="item.type==='select'"
          placeholder="请选择"
          v-model="form[item.model]"
      >
        <el-option
            v-for="item in item.opts"
            :key="item.value"
            :label="item.label"
            :value="item.value"
        ></el-option>
      </el-select>
    </el-form-item>
    <el-form-item><slot></slot></el-form-item>
  </el-form>
</template>

<script>
// script中书写组件交互相关的代码(数据、方法等)
export default {
  name: "CommonForm",
  props: {
    formLabel: Array,
    form: Object,
    inline: Boolean,
  },
  data() {
    return {}
  }
}
</script>

<style scoped>
/*style书写组建的样式*/

</style>